package com.qianyu.project.web.controller.sy;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qianyu.project.service.IContractChangeService;
import com.qianyu.project.utils.PageUtil;
import com.qianyu.project.utils.Result;
import com.qianyu.project.utils.ResultTool;
import com.qianyu.project.vo.ComplementSettlementExtend;
import com.qianyu.project.vo.ComplementSettlementVo;
import com.qianyu.project.vo.ContractChangeExtend;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("contractChange")
public class ContractChangeController {

    @Autowired
    private IContractChangeService contractChangeService;

    /**
     * 获取最大id
     * @return
     */
    @GetMapping("getMaxId")
    public Result getMaxId(){
        return ResultTool.success(Long.parseLong(contractChangeService.getMaxId()) + 1);
    }

    /**
     * 保存数据的方法
     * @param contractChangeExtend
     * @return
     */
    @PostMapping
    public Result save(@RequestBody ContractChangeExtend contractChangeExtend){
        contractChangeService.saveBoth(contractChangeExtend.getChangeForm(), contractChangeExtend.getChangeDetails());
        return ResultTool.success();
    }

    /**
     * 为列表查询数据
     * @param params
     * @return
     */
    @GetMapping
    public Result getList(@RequestParam Map<String, String> params){
        return ResultTool.success(contractChangeService.getList(params));
    }

    /**
     * 获取单个对象
     * @param id
     * @return
     */
    @GetMapping("{id}")
    public Result selectOne(@PathVariable String id){
        return ResultTool.success(contractChangeService.selectOne(id));
    }


}
